@extends('layout.adminlayout')
@section('css')
<script src="/admin/js/metisMenu.min.js"></script>
<script src="/admin/js/custom.js"></script>
<link href="/admin/css/custom.css" rel="stylesheet">
<link href="/admin/css/add_manage.css" rel="stylesheet">
@endsection
@section('content')
<div class="forms">
	<div class=" form-grids row form-grids-right">
		<div class="widget-shadow " data-example-id="basic-forms"> 
			<div class="form-title">
				<h4>添加区域 :</h4>
			</div>
			<div class="form-body">
				<form action="/admin/area/create" method="post" class="form-horizontal">
					{{csrf_field()}}
					<div class="form-group">
						<label for="inputEmail3" class="col-sm-2 control-label">
							区域名称 :
						</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" name="area_name" placeholder="区域名称" id="area_name">
						</div>
					</div>
					<div class="form-group">
						<label for="inputPassword3" class="col-sm-2 control-label">

						</label>
							<ul id="ul">
							</ul>
					</div>
					<div class="form-group">
						<label for="inputPassword3" class="col-sm-2 control-label">
							负责人 :
						</label>
						<div class="col-sm-9">
							<input type="text" class="form-control" name="manage" placeholder="管理员名称" id="manage" style="width: 1000px; float: left">
							<button type="button" class="btn btn-default" id="add" style="float: right">添加</button>
						</div>
					</div>
					<div class="col-sm-offset-2">
						<!-- <input type="submit" class="btn btn-default" value="Submit"> -->
						<button type="button" class="btn btn-default" id="sub">提交</button>
					</div>
				</form> 
			</div>
		</div>
	</div>
</div>
<script>
    //提交表单
	$('#sub').click(function () {
	    var area_name = $('#area_name').val();
	    var manage = new Array();
		$('.mng').each(function () {
			 manage.push($(this).html());
        });
		if(area_name !=''){
            $.ajax({
                type:'post',
                url:'/admin/area/create',
                async:false,
                data:{
                    "_token": $("input[name=_token]").val(),
                    'area_name':area_name,
                    'manage':manage
                },
                dataType:'json',
                success:function (data) {
					if(data.status == '1'){
					    location.href = '/admin/area/index';
					}
                }
            })
		}else{
		    alert('信息填写不完整')
            return false;
		}
    });
</script>
<script src="/admin/js/add_manage.js"></script>
@endsection